/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.levelup.trees;

import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 * @author WORKSPOT2
 */
public class TreeMapTest
{

    public static void main(String[] args)
    {
        TreeMap<Integer, String> map = new TreeMap<Integer, String>(new MyComparator());
        map.put(6, "The Six");
        map.put(2, "The Two");
        map.put(67, "Big number :)");
        map.put(16, "The Sixteen");
        map.put(26, "The Twenty six");
        map.put(3, "The Three");
        showMap(map);
        
        TreeMap<PlayerRatio,String> ratioMap = new TreeMap<PlayerRatio, String>();
        ratioMap.put(new PlayerRatio(1, 100), "Vasya");
        ratioMap.put(new PlayerRatio(2, 50), "Petya");
        ratioMap.put(new PlayerRatio(3, 150), "Kolya");
        ratioMap.put(new PlayerRatio(4, 200), "Deny");
        ratioMap.put(new PlayerRatio(5, 100500), "John");
        showMap(ratioMap);
        System.out.println("=========");
        Map<PlayerRatio,String> headTest = ratioMap.headMap(new PlayerRatio(-1, 160));
        showMap(headTest);
        Map<PlayerRatio, String> tailTest = ratioMap.tailMap(new PlayerRatio(-1, 170));
        System.out.println("=========");
        showMap(tailTest);
        
    }

    private static void showMap(Map map)
    {
        Iterator<Map.Entry> iter = map.entrySet().iterator();
        Map.Entry tmp;
        while (iter.hasNext())
        {
            tmp = iter.next();
            System.out.println(tmp.getKey() + " - " + tmp.getValue());
        }
    }
    
    
}
